package com.java110.mall.cart.bmo.housekeepingServFee.impl;

import com.java110.mall.cart.bmo.housekeepingServFee.IGetHousekeepingServFeeBMO;
import com.java110.intf.cart.IHousekeepingServFeeInnerServiceSMO;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.java110.dto.housekeeping.HousekeepingServFeeDto;

import java.util.ArrayList;
import java.util.List;

@Service("getHousekeepingServFeeBMOImpl")
public class GetHousekeepingServFeeBMOImpl implements IGetHousekeepingServFeeBMO {

    @Autowired
    private IHousekeepingServFeeInnerServiceSMO housekeepingServFeeInnerServiceSMOImpl;

    /**
     *
     *
     * @param  housekeepingServFeeDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> get(HousekeepingServFeeDto housekeepingServFeeDto) {


        int count = housekeepingServFeeInnerServiceSMOImpl.queryHousekeepingServFeesCount(housekeepingServFeeDto);

        List<HousekeepingServFeeDto> housekeepingServFeeDtos = null;
        if (count > 0) {
            housekeepingServFeeDtos = housekeepingServFeeInnerServiceSMOImpl.queryHousekeepingServFees(housekeepingServFeeDto);
        } else {
            housekeepingServFeeDtos = new ArrayList<>();
        }

        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) housekeepingServFeeDto.getRow()), count, housekeepingServFeeDtos);

        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);

        return responseEntity;
    }

}
